import React from 'react';
import {View} from 'react-native';
import List from '../list/List';
import DatePicker from './DatePicker';
import moment from "moment/moment";
import PopupStyles from './PopupStyles';

// const now = new Date();

export default class DatePickerDemo extends React.Component {
  constructor(props: any) {
    super(props);
    this.state = {
      value: new Date(),
    };
  }

  onChange = (value) => {
    this.setState({value});
  }

  onOk = (v) => {
    this.setState({value: v});
    console.log('DatePicker', v);
    console.log('DatePicker', moment(v).format('YYYY-MM-DD'));
  }

  render() {
    return (
      <View>

        <DatePicker
          styles={PopupStyles}
          value={this.state.value}
          title='日期选择'
          mode="date"
          minDate={new Date(2015, 7, 6)}
          maxDate={new Date(2026, 11, 3)}
          format="YYYY-MM-DD"
          onOk={this.onOk}
        >
          <List.Item arrow="horizontal">选择日期</List.Item>
        </DatePicker>

      </View>
    );
  }
}
